package ru.autofan.action;

import org.springframework.webflow.execution.Event;
import org.springframework.webflow.execution.RequestContext;

import ru.autofan.form.AddCarForm;
import ru.autofan.logic.CarService;

public class AddCarAction extends AbstractAction {

	public Event save(RequestContext context) throws Exception {
		AddCarForm form = (AddCarForm) getFormObject(context);
		getService(CarService.class).addCar(form);
		return success();
	}

	public Event addCar(RequestContext context) throws Exception {
		AddCarForm form = (AddCarForm) getFormObject(context);
		if (form.getFile() != null && form.getFile().getSize() > 0
				) {
			form.getUploadedFiles().add(form.getFile());
			
		}
		return success();
	}

}
